home *** CD-ROM | disk | FTP | other *** search
/ PC Player 2004 May / pc player 2004-05.iso / Demos / FarCry / Data1.cab / _4B9E9F4C109A40EC90868FAD90A6DA48 < prev    next >
Encoding:
Text File  |  2004-01-06  |  3.7 KB  |  127 lines

  1.       #include "../CGVPMacro.csi"
  2.  
  3.       AutoEnumTC
  4.  
  5.       MainInput
  6.       {
  7.         uniform sampler2D shadMap0 : register(sn),
  8. #if %TEMP_SHAD_SAMPLEMASK1
  9.         uniform sampler2D shadMap1 : register(sn),
  10. #endif        
  11. #if %TEMP_SHAD_SAMPLEMASK2
  12.         uniform sampler2D shadMap2 : register(sn),
  13. #endif        
  14.         uniform sampler2D baseMap : register(sn),
  15.         uniform float4 Ambient,
  16.         uniform float4 Fading,
  17. #if %ENVCMAMB
  18.         uniform float4 Reflect,
  19.         uniform samplerCUBE envMap : register(sn),
  20. #endif        
  21.       }
  22.       DeclarationsScript
  23.       {
  24.         // define outputs from vertex shader
  25.         struct vertout
  26.         {
  27.           float4 HPosition  : POSITION;
  28.           float4 shadTC0     : TEXCOORDN;
  29. #if %TEMP_SHAD_SAMPLEMASK1
  30.           float4 shadTC1     : TEXCOORDN;
  31. #endif
  32. #if %TEMP_SHAD_SAMPLEMASK2
  33.           float4 shadTC2     : TEXCOORDN;
  34. #endif
  35.           float4 baseTC      : TEXCOORDN;
  36.           
  37. #if %TEMP_MIXED_MAP
  38.           float4 depthTC0    : TEXCOORDN;
  39.     #if %TEMP_SHAD_SAMPLEMASK2
  40.           float4 depthTC1    : TEXCOORDN;
  41.     #endif
  42. #endif
  43.  
  44. #if %ENVLIGHT
  45.           float4 Color      : COLOR0;
  46. #elif %ENVCMAMB
  47.           float4 envTC      : TEXCOORDN;
  48. #endif
  49.         };
  50.  
  51.         FOUT
  52.       }
  53.       CoreScript
  54.       {
  55.         float3 shad = (float3)0;
  56.         float3 compare = (float3)0;
  57.         
  58.         // load the decal
  59.         float4 decalColor = tex2D(baseMap, IN.baseTC.xy);
  60.         // load the 3 shadow samples
  61.         float4 shadColor0 = tex2Dproj(shadMap0, IN.shadTC0.xyzw);
  62.         shad.x = shadColor0.r/8 + shadColor0.g;
  63. #if %TEMP_SHAD_SAMPLEMASK1
  64.         float4 shadColor1 = tex2Dproj(shadMap1, IN.shadTC1.xyzw);
  65.         shad.y = shadColor1.r/8 + shadColor1.g;
  66. #endif        
  67. #if %TEMP_SHAD_SAMPLEMASK2
  68.         float4 shadColor2 = tex2Dproj(shadMap2, IN.shadTC2.xyzw);
  69.         shad.z = shadColor2.r/8 + shadColor2.g;
  70. #endif        
  71. #if %TEMP_DEPTH_MAP
  72.   // Using NVidia Depth textures
  73.         compare.x = 1-shadowColor0.b;
  74.   #if %TEMP_SHAD_SAMPLEMASK1
  75.         compare.y = 1-shadowColor1.b;
  76.   #endif        
  77.   #if %TEMP_SHAD_SAMPLEMASK2
  78.         compare.z = 1-shadowColor2.b;
  79.   #endif        
  80.         compare.xyz = vShadow.xyz * Fading.xyz;
  81. #elif %TEMP_MIXED_MAP
  82.   // Using PS2.0 Z-Comparing (mixed 2D/Depth technique)
  83.         float3 vZ = (float3)0;
  84.         vZ.x = IN.depthTC0.x / IN.depthTC0.y;
  85.     #if %TEMP_SHAD_SAMPLEMASK1
  86.         vZ.y = IN.depthTC0.z / IN.depthTC0.w;
  87.     #endif        
  88.     #if %TEMP_SHAD_SAMPLEMASK2
  89.         vZ.z = IN.depthTC1.x / IN.depthTC1.y;
  90.     #endif
  91.         shad = shad - vZ;
  92.         compare = step(shad, float3(0.0, 0.0, 0.0));
  93.         compare.xyz = compare.xyz * Fading.xyz;
  94.         compare.x = compare.x * shadColor0.a;
  95.     #if %TEMP_SHAD_SAMPLEMASK1
  96.         compare.y = compare.y * shadColor1.a;
  97.     #endif
  98.     #if %TEMP_SHAD_SAMPLEMASK2
  99.         compare.z = compare.z * shadColor2.a;
  100.     #endif
  101. #else
  102.   // Using 2D shadow maps (simplest technique)
  103.         compare.x = shadowColor0.a;
  104.     #if %TEMP_SHAD_SAMPLEMASK1
  105.         compare.y = shadowColor1.a;
  106.     #endif
  107.     #if %TEMP_SHAD_SAMPLEMASK2
  108.         compare.z = shadowColor2.a;
  109.     #endif
  110.         compare.xyz = compare.xyz * Fading.xyz;
  111. #endif
  112.  
  113.         float fCompare = dot(compare, float3(1, 1, 1));
  114. #if %ENVLIGHT
  115.         half3 amb = decalColor.xyz * IN.Color.xyz;
  116. #elif %ENVCMAMB
  117.         // load the environment map
  118.         half4 envColor = texCUBE(envMap, IN.envTC.xyz);
  119.         half3 amb = lerp(decalColor.xyz*Ambient.xyz, envColor.xyz, Reflect.a);
  120. #else        
  121.         half3 amb = decalColor.xyz * Ambient.xyz;
  122. #endif        
  123.         OUT.Color.xyz = amb.xyz;
  124.         OUT.Color.a = fCompare;
  125.       }
  126.       
  127.